package com.ruoyi.platform.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.platform.domain.TRechargeFlow;
import com.ruoyi.platform.service.ITRechargeFlowService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 充值流水Controller
 * 
 * @author ruoyi
 * @date 2025-08-20
 */
@RestController
@RequestMapping("/flow")
public class TRechargeFlowController extends BaseController
{
    @Autowired
    private ITRechargeFlowService tRechargeFlowService;

    /**
     * 查询充值流水列表
     */
    @RequiresPermissions("platform:flow:list")
    @GetMapping("/list")
    public TableDataInfo list(TRechargeFlow tRechargeFlow)
    {
        startPage();
        List<TRechargeFlow> list = tRechargeFlowService.selectTRechargeFlowList(tRechargeFlow);
        return getDataTable(list);
    }

    /**
     * 导出充值流水列表
     */
    @RequiresPermissions("platform:flow:export")
    @Log(title = "充值流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TRechargeFlow tRechargeFlow)
    {
        List<TRechargeFlow> list = tRechargeFlowService.selectTRechargeFlowList(tRechargeFlow);
        ExcelUtil<TRechargeFlow> util = new ExcelUtil<TRechargeFlow>(TRechargeFlow.class);
        util.exportExcel(response, list, "充值流水数据");
    }

    /**
     * 获取充值流水详细信息
     */
    @RequiresPermissions("platform:flow:query")
    @GetMapping(value = "/{flowId}")
    public AjaxResult getInfo(@PathVariable("flowId") Long flowId)
    {
        return success(tRechargeFlowService.selectTRechargeFlowByFlowId(flowId));
    }

    /**
     * 新增充值流水
     */
    @RequiresPermissions("platform:flow:add")
    @Log(title = "充值流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TRechargeFlow tRechargeFlow)
    {
        return toAjax(tRechargeFlowService.insertTRechargeFlow(tRechargeFlow));
    }

    /**
     * 修改充值流水
     */
    @RequiresPermissions("platform:flow:edit")
    @Log(title = "充值流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TRechargeFlow tRechargeFlow)
    {
        return toAjax(tRechargeFlowService.updateTRechargeFlow(tRechargeFlow));
    }

    /**
     * 删除充值流水
     */
    @RequiresPermissions("platform:flow:remove")
    @Log(title = "充值流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{flowIds}")
    public AjaxResult remove(@PathVariable Long[] flowIds)
    {
        return toAjax(tRechargeFlowService.deleteTRechargeFlowByFlowIds(flowIds));
    }
}
